package com.hqyj.module.holiday.controller;

import com.github.pagehelper.PageInfo;
import com.hqyj.module.clock.pojo.SearchBean;
import com.hqyj.module.holiday.pojo.Holiday;
import com.hqyj.module.holiday.service.HolidayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author lap
 * @version 1.0
 * @date 2021/10/8 10:48
 */

@RestController
@RequestMapping("/user-info")
public class MyHolidayController {
    @Autowired
    HolidayService holidayService;

    @GetMapping("/saveHoliday")
    public Map<String, Object> insertHoliday(Holiday holiday) {
        Map<String, Object> map = holidayService.insertHoliday(holiday);
        return map;
    }

    @GetMapping("/getUserInfo")
    public Map<String, Object> getUserInfo(Integer userId) {
        Map<String, Object> map = holidayService.getUserInfo(userId);
        return map;
    }

    @GetMapping("/getHolidays")
    public List<Holiday> getHolidays(Integer userId) {
        List<Holiday> holidays = holidayService.getHolidays(userId);
        return holidays;
    }

    @GetMapping(value = "/clocks")
    public PageInfo<Holiday> getCitiesBySearchBean(int currentPage, int pageSize) {
        SearchBean searchBean = new SearchBean();
        searchBean.setCurrentPage(currentPage);
        searchBean.setPageSize(pageSize);
        PageInfo<Holiday> citiesBySearchBean = holidayService.getCitiesBySearchBean(searchBean);
        return citiesBySearchBean;
    }

    @GetMapping(value = "/clocksBusiness")
    public PageInfo<Holiday> getBusinessBySearchBean(int currentPage, int pageSize) {
        SearchBean searchBean = new SearchBean();
        searchBean.setCurrentPage(currentPage);
        searchBean.setPageSize(pageSize);
        PageInfo<Holiday> citiesBySearchBean = holidayService.getBusinessBySearchBean(searchBean);
        return citiesBySearchBean;
    }

    @GetMapping(value = "/clocksBusinessApp")
    public PageInfo<Holiday> getBusinessBySearchBeanApp(int currentPage, int pageSize,String keyWorld) {
        SearchBean searchBean = new SearchBean();
        searchBean.setCurrentPage(currentPage);
        searchBean.setPageSize(pageSize);
        searchBean.setKeyword(keyWorld);
        PageInfo<Holiday> citiesBySearchBean = holidayService.getBusinessBySearchBeanApp(searchBean);
        return citiesBySearchBean;
    }

    @GetMapping(value = "/clocksThingApp")
    public PageInfo<Holiday> getThingBySearchBeanApp(int currentPage, int pageSize,String keyWorld) {
        SearchBean searchBean = new SearchBean();
        searchBean.setCurrentPage(currentPage);
        searchBean.setPageSize(pageSize);
        searchBean.setKeyword(keyWorld);
        PageInfo<Holiday> citiesBySearchBean = holidayService.getThingBySearchBeanApp(searchBean);
        return citiesBySearchBean;
    }


}
